fix(angular-query): track pre-render query promises#10779
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughWraps query functions to register Angular pending tasks for thenables, centralizes observer updates into updateState so Angular's whenStable() remains pending when a query data signal is accessed before initial render, adds tests and a changeset, and narrows QueryClient.resetQueries refetches to matched queries only. ChangesKeep Angular whenStable() pending when query data accessed early
QueryClient.resetQueries: restrict refetch set
Sequence Diagram(s)sequenceDiagram
participant Component as AngularComponent
participant QueryFn as defaultedOptions.queryFn (wrapper)
participant Pending as PendingTaskRegistry
participant Observer as QueryObserver
participant UpdateState as updateState
participant Zone as ngZone
participant Signal as resultFromSubscriberSignal
Component->>QueryFn: invoke queryFn (may return thenable)
QueryFn->>Pending: register pending task callback for thenable
Observer->>UpdateState: emits new result (next/error)
UpdateState->>Zone: run updates inside ngZone.run
Zone->>Pending: complete/unregister pending task based on fetchStatus
UpdateState->>Signal: update resultFromSubscriberSignal with latest result
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/angular-query-experimental/src/create-base-query.ts`:
- Around line 70-75: The pendingTasks.add() ref created for thenable results in
create-base-query.ts can be leaked if the thenable never settles; modify the
thenable handling around result.then(...) to ensure the pendingTaskRef is
released exactly once on cancellation/destruction: if an AbortSignal is present
in the query context, register a one-time abort listener that calls
pendingTaskRef() and removes itself; otherwise hook into the query
cancellation/cleanup path (the same place that cancels the request) to call
pendingTaskRef(); ensure both the result.then fulfillment/rejection handlers and
the cancellation listener invoke pendingTaskRef() idempotently (guarded so it
only runs once) and that any registered listener is removed after release.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5cca70e1-f9cd-4f4f-8a96-a4451e588fd6
📒 Files selected for processing (3)
.changeset/angular-query-preaccess-whenstable.mdpackages/angular-query-experimental/src/__tests__/inject-query.test.tspackages/angular-query-experimental/src/create-base-query.ts
Fixes #10046.
Summary
PendingTasksfor promise-returning query functions as soon as the query function runsquery.datathat is read during render beforewhenStable()@tanstack/angular-query-experimentalValidation
corepack pnpm install --frozen-lockfilecorepack pnpm --filter @tanstack/angular-query-experimental exec vitest run src/__tests__/signal-proxy.test.ts src/__tests__/inject-query.test.ts(2 files, 27 tests passed)corepack pnpm exec eslint packages/angular-query-experimental/src/create-base-query.ts packages/angular-query-experimental/src/__tests__/inject-query.test.tscorepack pnpm exec prettier --check .changeset/angular-query-preaccess-whenstable.md packages/angular-query-experimental/src/create-base-query.ts packages/angular-query-experimental/src/__tests__/inject-query.test.tsgit diff --checkI also ran
corepack pnpm --filter @tanstack/angular-query-experimental exec vitest run; all Angular package tests executed successfully (25 files, 218 tests passed), but the command exited non-zero because this Windows checkout treats repo symlink placeholders likeroot.eslint.config.jsas source and reportsTypeCheckError: Declaration or statement expected.corepack pnpm --filter @tanstack/query-core buildis blocked by the same local symlink placeholder issue inpackages/query-core/root.tsup.config.js.Summary by CodeRabbit
Bug Fixes
Behavior Changes
Tests
Chores